
fetch('http://chst.vip:1234/api/getindexmenu')
.then(function(respond){
    return respond.json();
})
.then(function(res){
    console.log(res);
    let str='';
    res.result.forEach(item => {
        let a=item.img.split('"')[1]
        str +=`<div titlehref='${item.titlehref}'>
                    <img src="http://chst.vip:8081/for-stu/wfzh/${a}" alt="">
                    <p>${item.name}</p>
                </div>`
    });
    let main = document.querySelector('main')
    main.innerHTML=str;

    main.onclick=function(ev){
        let e = ev || window.event;
        let target = e.target || e.srcElement;
        
        let c;
        if(target.nodeName==='DIV'){
            c=target.getAttribute('titlehref')
        }else{
            c=target.parentNode.getAttribute('titlehref')
        }
        console.log(c);
        console.log(this);
        if(c!=='#'){
            location.href=`./${c}`

        }else{
           $('main div:eq(7)').nextAll().slideToggle();
        }
       
    }
})
fetch('http://chst.vip:1234/api/getmoneyctrl')
.then(function(respond){
    return respond.json()
})
.then(function(a){
    console.log(a);
    let str1 = '';
    a.result.forEach(item => {
        let c = item.productImgSm.split(' ')[1].split('=')[3]
        console.log(c);
        str1 +=`<a productId=${item.productId}>
                    <img src="${c}">
                    <div class="right">
                        <div class="top">
                        ${item.productName}<span>${item.productPinkage}</span>
                        </div>
                        <div class="bottom">
                            <span>${item.productFrom}|${item.productTime}</span>
                            <span class="iconfont icon-xiaoxi"></span>
                            <span>${item.productComCount}</span>
                        </div>
                    </div>
                 </a>`
        let box = document.querySelector('#box')
        box.innerHTML=str1;
    });
})
.then(function(){
    $('#box').on('click','a',function(){
        let productId = $(this).attr('productId')
        console.log(productId);
        location.href='./moneyctrl_1.html?productId='+productId;
    })
})